package com.mall.service.eshop;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.mall.client.eshop.EshopTrademarkService;
import com.mall.custom.dao.read.EshopTrademarkReadMapper;
import com.mall.custom.dao.write.EshopTrademarkWriteMapper;
import com.mall.pojo.EshopTrademark;
@Service
public class EshopTrademarkServiceImpl implements EshopTrademarkService {

	@Autowired
	private EshopTrademarkReadMapper eshopTrademarkReadMapper;
	@Autowired
	private EshopTrademarkWriteMapper eshopTrademarkWriteMapper;
	
	/**
	 * 查找商标信息
	 * @param id
	 * @return
	 */
	@Override
	public EshopTrademark getEshopTrademarkByEshopTrademarkId(Long id) {
		if(id == null || id <= 0){
			return null;
		}
		return this.eshopTrademarkReadMapper.selectByPrimaryKey(id);
	}

	/**
	 * 添加商标信息
	 * @param eshopTrademark
	 * @return
	 */
	@Override
	public int insertEshopTrademarkByEshopTrademark(EshopTrademark eshopTrademark) {
		// TODO Auto-generated method stub
		return this.eshopTrademarkWriteMapper.insert(eshopTrademark);
	}

	/**
	 * 修改商标信息
	 * @param eshopTrademark
	 * @return
	 */
	@Override
	public int modifyEshopTrademarkByEshopTrademark(EshopTrademark eshopTrademark,EshopTrademark existEshopTrademark) {
		if(existEshopTrademark != null){
			eshopTrademark.setId(existEshopTrademark.getId());
			eshopTrademark.setSaleEshopId(existEshopTrademark.getSaleEshopId());
			eshopTrademark.setGmtCreate(existEshopTrademark.getGmtCreate());
		}
		return this.eshopTrademarkWriteMapper.updateByPrimaryKey(eshopTrademark);
	}

	/**
	 * 删除商标信息
	 * @param id
	 * @return
	 */
	@Override
	public int deleteEshopTrademarkByEshopTrademarkId(Long id) {
		// TODO Auto-generated method stub
		return this.eshopTrademarkWriteMapper.deleteByPrimaryKey(id);
	}

	@Override
	public int modifyEshopTrademarkByKey(EshopTrademark eshopTrademark) {
		// TODO Auto-generated method stub
		return this.eshopTrademarkWriteMapper.updateByPrimaryKey(eshopTrademark);
	}

}
